<%@ include file="/common/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><spring:message code="dashboard.title"/></title>
<script>
 function windowchangeMSG(){
 		    var content = $('#content:first').find('div:first').attr('id');
		     var msg = '';
		    if(content !=undefined){
		     var msg1='open form. Unsaved data will be lost. Click on cancel to continue working on this form';
		     if(content=='editDonorDiv' && $("#donorName").attr('disabled')==undefined)msg='You have "Donor- Add" ' + msg1;
		     if(content=='editDonorawardDiv' && $("#donorAwardNumber").attr('disabled')==undefined)	msg='You have "Donor Award - Add" ' + msg1;
		     if(content=='editCipeprojectDiv' && $("#donorawardId").attr('disabled')==undefined)msg='You have "Project - Add/Edit" ' + msg1;
		     if(content=='editPartnergrantDiv')msg='You have "Partner Grant - Add" ' + msg1;
		     if(content=='editPaymentrequestDiv' && $("#payeeId").attr('disabled')==undefined)msg='You have "Payment Request - Add" ' + msg1;
		     if(content=='editUserDiv')msg='You have "Manage Users" ' + msg1;
		     if(content=='editRoleDiv')msg='You have "Manage Roles" ' + msg1;
		     if(content=='editRegionDiv')msg='You have "Manage Regions" ' + msg1;
		     if(content=='editCountryDiv')msg='You have "Manage Countries" ' + msg1;
		     if(content=='editStateDiv')msg='You have "Manage States" ' + msg1;
		     if(content=='editFieldofficeDiv')msg='You have "Manage Field Offices " ' + msg1;
		     if(content=='editDonorawardstatusDiv')msg='You have "Manage Donor Award Statuses " ' + msg1;
		     if(content=='editCipeprojecttypeDiv')msg='You have "Manage Project Types " ' + msg1;
		     if(content=='editKeywordDiv')msg='You have "Manage Knowledge Management Keywords " ' + msg1;
		     if(content=='changePasswordDiv')msg='You have "Change Password " ' + msg1;     
		     if(content=='editKnowledgeManagementDiv' && $("#themebusassocdev").attr('disabled')==undefined)msg='You have "Catalog Management " ' + msg1;
		     if(content=='editRepReqsDiv' && ($("#periodStartDateNar0").attr('disabled')==undefined || $("#periodStartDateFin0").attr('disabled')==undefined) )msg='You have "Reporting Requirements " ' + msg1;
		     if(content=='editAccountCodeDiv')msg='You have "Account Code " ' + msg1;
		     if(content=='editOrganizationtypeDiv')msg='You have "Manage Knowledge Management Organization Types " ' + msg1;
		     if(content=='editCipeprojectstatusDiv')msg='You have "Manage Project Statuses " ' + msg1;
		     if(content=='editDonorawardtypeDiv')msg='You have "Manage Donor Award Types " ' + msg1;
		     if(content=='editAuditsDiv' && $("#smponly1").attr('disabled')==undefined)msg='You have "Partner Monitoring " ' + msg1;          
		     }
		   return msg; 
 }
function updatecn(id){
		$('<div>Are you sure that you want to remove this Change Notification ?</div>').dialog({
				modal: true,
				height: 150,
				width: 400,
				dialogClass: 'confirmationDialog',
				buttons: 
			          {
						'Yes' : function() {
							$(this).dialog('close');
							loadDiv('cnContent', 'changeNotification.do?id='+id);
						},
						'No' : function() {
							$(this).dialog('close');
						}
			          },
			  	close: function(event, ui) {
			  		$(this).dialog('destroy');		  		
			  	}
			});
}

function filterActionalert(){
	var id=document.filterAlert.aaid.value;
	var dateid=document.filterAlert.aaDateid.value;
	var asignid=document.filterAlert.aaAsignId.value;
	var regionid=document.filterAlert.aaReagionId.value;
		
	loadDiv('actionalertContent', 'actionalertFilterDashboard.do', null, {
		'aaid' : id,
		'aaDateid' : dateid,
		'aaAsignId' : asignid,
		'aaReagionId' : regionid
	});	
}

function filterCN(){
	var id=document.filterCNFrom.cnid.value;
	var dateid=document.filterCNFrom.cnDateid.value;
	var asignid=document.filterCNFrom.cnAsignId.value;
	var regionid=document.filterCNFrom.cnReagionId.value;
	loadDiv('cnContent', 'changeNotificationFilterDashboard.do', null, {
		'cnid' : id,
		'cnDateid' : dateid,
		'cnAsignId' : asignid,
		'cnReagionId' : regionid
	});	
}

function filterproject(){
	var id=document.projectfilter.projectAsignId.value;
	var regionid=document.projectfilter.projectReagionId.value;
	loadDiv('p1', 'filterProject.do', null, {
		'projectAsignId' : id,
		'projectReagionId' : regionid
	});
}
function filterpayment(){
	var id=document.projectfilter.paymentAssingId.value;
	loadDiv('p2', 'filterPayment.do', null, {
		'paymentAssingId' : id
	});
}

function filterpartner(){
	var id=document.partnerfilter.partnerAsignId.value;
	var regionid=document.partnerfilter.partnerReagionId.value;
	loadDiv('p3', 'filterPartner.do', null, {
		'partnerAsignId' : id,
		'partnerReagionId' : regionid	
	});
}

$(document).ready(function() {
	$('#pageTitle').text('');
	
	$(window).bind("beforeunload",function(event) {
	    var msg = windowchangeMSG();	   
    	if(msg !=''){
    	   return msg;
    	}
	});
		
		$('.links li a').click(function() {
			$(this).bind("ajaxSend", function(){
				$('#loading').remove();
				$(this).after("<img  id='loading' src='<c:url value='/images/ajax-loader(1).gif'/>' alt='loading' />");

				 }).bind("ajaxComplete", function(){

					$('#loading').remove();

				 });
            var msg = windowchangeMSG();
		    if(msg!=''){
		     	var ans=window.confirm(msg);		     
		     	if(!ans)return;
		      }
		    if( $(this).attr('url')=='showEmailGrantManagement.do')
		    {
		      	window.location.href = "mailto:grantsmanagement@cipe.org, helpdesk@cipe.org";		      
		    }else if( $(this).attr('url')=='reportComputerProblem.do')
		    {
		      	window.location.href = "mailto:helpdesk@cipe.org";
	      
		    } else if( $(this).attr('url')=='systemReq.do')
		    {
		    	window.location.href = "mailto:database@cipe.org, helpdesk@cipe.org"; 		    
		    } else 
		    {
				loadDiv('content', $(this).attr('url'));
			}
			
			$('.links li a').removeClass('active');
			$(this).addClass('active');
		});
	
		$('.cndl').click(function() {
			loadDiv('content', $(this).attr('url'));
		});

		$('.andl').click(function() {
			loadDiv('content', $(this).attr('url'));
		});
	
		var locked=true;
			
		$('.link-heading').click(function() { 
			if($(this).attr('mostate')=='hide'&&$(this).attr('moclick')=='hide'){
			$(this).next().slideToggle('fast');
			$(this).find('span.ui-icon').toggleClass('ui-icon-triangle-1-s');
			$(this).attr('moclick','show');	
			}
			
			else if($(this).attr('moclick')=='show'){
				$(this).next().slideToggle('fast');
				$(this).find('span.ui-icon').toggleClass('ui-icon-triangle-1-s');
				$(this).attr('moclick','hide');
				$(this).attr('mostate','hide');
			}
			if($(this).attr('mostate')=='show'){
			$(this).attr('moclick','show');
			$(this).attr('mostate','hide');
			
			}
			
		});
		

		$('#changePasswordLink').click(function() {
			loadDiv('content', $(this).attr('url'));
		});
		
		$('#btnBack').click(function() {
			var url = $(this).attr('href');
			if('' != url) {
				loadDiv('content', url);
			}
		});
		
		$('#btnForward').click(function() {
			var url = $(this).attr('href');		
			if('' != url) {
				loadDiv('content', url);
			}
		});
	});
		$('#pageRefresh').click(function() {
			location.reload();
		});

</script>
</head>

<body>
<div id="header">
    <div id="logo">
    	<a href="../secure/showDashboard.do" id="logoLink" url='showDashboard.do'>
    		<img src="<c:url value='/images/cipe-banner-new.png'/>"  alt="CIPE logo" /></a>
    </div>
	<div id="pageTitle"></div>    
    <div id="banner">
    <br/>
    <spring:message code="baner.title" />
    </div>
    <br class="clear" />
</div>

<div class="cipe-sub-nav">
    <ul class="floatL">
        <li><a href="../secure/showDashboard.do" id="crmsHomeLink" class="active"><spring:message code="dashboard.tabs.crms.home" /></a></li>
        <li><a href="javascript:void(0);" id="changePasswordLink"  url='showChangePassword.do'>Change Password</a></li>
        <li><a href="../logout.do">Logout</a></li>
        <li class="cipe-username">Welcome, ${user.firstName}&nbsp;${user.lastName}</li>
   </ul>
   <ul class="floatR">     
		<li><a href="javascript:window.print()">Print</a></li>
		<li><a href="#" onclick="return false;" id="btnBack">Back</a></li>
		<li><a href="#" onclick="return false;" id="btnForward">Forward</a></li>
    </ul>
    <br class="clear" />
</div>
<div class="main_cont">
	<div id="left">
		<c:forEach items="${linkCategories}" var="linkCategory" varStatus="status">
			<div class="links-main">
				<c:set var="class" value="" />
				<c:set var="display" value="none" />
				<c:if test="${status.first }">
					<c:set var="class" value="ui-icon-triangle-1-s" />
					<c:set var="display" value="none"/>
				</c:if>
				<div class="link-heading" mostate='hide' moclick='hide'>
					<span class="ui-icon ui-icon-triangle-1-e" style="float: left;"></span>
					<span style="position: relative; top: 2px;">${linkCategory.name}</span>
				</div>
				<div class="links" style="display: ${display};font-weight:normal; padding: 0px 0px 0px 0px;" >
					<ul>
						<c:forEach items="${linkCategory.links}" var="link">						
						 <c:if test="${link.url!='findPartnergrant.do'}">
							<li><a href="javascript://" url="${link.url}">${link.name}</a></li>
						 </c:if>	
						</c:forEach>
					</ul>
				</div>
			</div>
		</c:forEach>
	</div>
    <div id="content">
	 <jsp:include page="dashboardDiv.jsp" />
    </div>
</div>
</body>
</html>